#!/usr/bin/env node

const commander = require('commander');
const chalk = require('chalk');
const packageJson = require('./package.json');
const create = require('./src/index');


/**
 * 项目名称
 */
let projectName;

const program = new commander.Command(packageJson.name)
    .arguments('<projectName>')
    .version('v' + packageJson.version, '-v, --version')
    .option('-f, --force', '强制删除重名文件夹并创建')
    // .alias('cp')
    .description('create-tj-react-app myProject')
    .action(function (name, command) {
        //获取项目名称
        projectName = name;
    });

program.parse(process.argv);

/* 判断创建命令是否正确*/
if (program.args.length === 0) {
    console.log(chalk.red('语法错误!'));
    program.help()
}
/* 创建工程 */
if (projectName) {
    create(projectName, program.force);
}